package com.dayaokeji.rhythmschoolstudent.view;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.FrameLayout;
import android.widget.ProgressBar;
import android.widget.TextView;

import com.dayaokeji.rhythmschoolstudent.R;
import com.orhanobut.logger.Logger;

/**
 * Created by Gorden on 2017/10/9.
 */

public class VoteResultItemView extends FrameLayout {


    private float progress;
    private String voteName;
    private View rootView;
    private int count;

    public VoteResultItemView(Context context,float progress,String voteName,int count) {
        super(context);
        this.progress = progress;
        this.voteName = voteName;
        this.count = count;
        init(context);
    }

    private void init(Context context) {
        if (rootView == null) {
            rootView = LayoutInflater.from(context).inflate(R.layout.vote_result_item_view, null, false);
        }
        
        final ProgressBar pbVoteCount = (ProgressBar) rootView.findViewById(R.id.pb_vote_count);
        final TextView tvCount = (TextView) rootView.findViewById(R.id.tv_count);
        final TextView tvVoteItem = (TextView) rootView.findViewById(R.id.tv_vote_item);

        pbVoteCount.setProgress((int) (progress * 100));
        tvCount.setText(String.valueOf(count));
        tvVoteItem.setText(voteName);

        this.addView(rootView);

    }
}
